﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_ManageDownload_SearchRoleControl

    Public Sub New()

    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal FileSaveName As String) As DataTable

        Dim dat As New clsData

        Dim sql As New MyStringBuilder
        sql.AppendFormat("SELECT A.RoleName,A.RoleID,CASE WHEN B.RoleID is null THEN '1' ELSE '0' END as IsEnable  ")
        sql.AppendFormat("FROM Role A ")
        sql.AppendFormat("LEFT JOIN RoleFileMapping B on A.RoleID = B.RoleID and B.FileSaveName='{0}' ", FileSaveName)
        sql.AppendFormat("WHERE A.Active='Y' ")
        sql.AppendFormat("ORDER BY IsEnable desc,A.RoleID asc")

        Return dat.GetData(sql)

    End Function

End Class
